/*
 * Copyright 2008-2009 ArtisanLogic.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.artisanlogic.io;

import java.io.Closeable;

// =====================================================================================================================
// StreamTemplate.java                                                                           Created on Feb 19, 2009
// ---------------------------------------------------------------------------------------------------------------------
/**
 * This interface is a behavior specification for implementations of the Template Method pattern for I/O operations that
 * operate on input or output streams.
 * 
 * @author sean@artisanlogic.com
 * @since 0.9-Beta
 */
// =====================================================================================================================
public interface StreamTemplate<StreamType extends Closeable> {
  
  // -------------------------------------------------------------------------------------------------------------------
  // public abstract methods
  // -------------------------------------------------------------------------------------------------------------------
  
	/**
	 * This method delegates to the provided task to perform an I/O operation handling mapping checked exceptions to 
	 * appropriate unchecked exceptions.
	 * 
	 * @param task This parameter holds the task to delegate situation-specific stream creation / acquisition and I/O 
	 *   operations to.
	 * @throws RuntimeException This method throws an instance of RuntimeException if an unrecoverable error is 
	 *   encountered while performing / managing the provided StreamTask.
	 */
	void withStream(StreamTask<StreamType> task) throws RuntimeException;

}
